<?php

namespace app\daili\controller;

use think\facade\Db;

use think\facade\Request;


class Pay extends  Base

{


	public function list() {
 $loginAdmin=session('dailiAccount'); 
		    $daili=Db::name('daili')->where('id',$loginAdmin['id'])->find();
      if($daili['shoukuan']==1){
            return alert('您的权限不足，请联系上级升级!','/daili/index',5,3); 
            exit;
        }
		
		$payData=Db::name('pay')->where('uid',$loginAdmin['id'])->order('id desc')->select();

		return view('', [

			'payData' => $payData,
		
		]);

	}

 public function add() {
 $loginAdmin=session('dailiAccount'); 
		if(request()->isPost()) {

			// 入库的逻辑

			$data = input('post.');
			unset($data['file']);
            $data['uid'] = $loginAdmin['id'];
			$res = Db::name('pay')->insert($data);

			if($res){
				return alert('操作成功！','list',6,3);
			 }else{
				return alert('操作失败！','list',5,3);
			 }

		}

return view('', [

		
		
		]);

	}
	public function edit(){
 $loginAdmin=session('dailiAccount'); 
		$id = input('id');

		$payData=Db::name('pay')->find($id);
		if(request()->isPost()){

			$data=input('post.');
			unset($data['file']);
			 $data['uid'] =$loginAdmin['id'];
            $res=Db::name('pay')->where('id',$id)->update($data);

			if($res){
				return alert('操作成功！','list',6,3);
			 }else{
				return alert('操作失败！','list',5,3);
			 }

		}

		return view('', [

				'payData' => $payData,
			
			]);

	}







	public function del(){
	     $loginAdmin=session('dailiAccount'); 
		    $daili=Db::name('daili')->where('id',$loginAdmin['id'])->find();
      if($daili['shoukuan']==1){
            return alert('您的权限不足，请联系上级升级!','/daili/index',5,3); 
            exit;
        }
		$id=Request::instance()->param('id');
	
		
		$res=Db::name('pay')->where('id',$id)->delete();
		if($res){
			return alert('操作成功！','index',6,3);
		 }else{
			return alert('操作失败！','index',5,3);
		 }
	}
	





}

